#include <bits/stdc++.h>
using namespace std;
int c[105];
int main(){
    int n;
    cin>> n;
    for (int i = 1; i <= n; i++){
        cin >> c[i];
    }
    int x, cnt = 0;
    cin >> x;
    for (int i = 1; i <= n; i++){
        if (x >= c[i]){
            x -= c[i];
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}